from django.db import models


# Create your models here.
class FoodList(models.Model):
    menu_name = models.CharField(max_length=64)
    pro_id = models.CharField(max_length=32)
    pro = models.CharField(max_length=64, null=True)
    en_pro = models.CharField(max_length=32, null=True)
    price = models.IntegerField(max_length=32, null=True)
    img = models.CharField(max_length=64, null=True)

    def __unicode__(self):
        return self.pro


class MemberList(models.Model):
    phone = models.CharField(max_length=64, unique=True)
    pwd = models.CharField(max_length=32, null=True)
    reg_date = models.CharField(max_length=64)


class RecorderList(models.Model):
    p_phone = models.CharField(max_length=64, null=True)
    p_off_total = models.CharField(max_length=64, null=True)
    p_result = models.CharField(max_length=64)
    p_times = models.DateTimeField(max_length=64, auto_now_add=True)

    def __unicode__(self):
        return u'%s %s' % (self.id, self.p_times)


class BillList(models.Model):
    p_pro = models.ForeignKey(FoodList, on_delete=models.CASCADE)
    p_num = models.IntegerField()
    p_sum = models.CharField(max_length=64)
    p_recorder = models.ForeignKey(RecorderList, on_delete=models.CASCADE)

    def __unicode__(self):
        return u'%s %s' % (self.p_pro.pro, self.p_recorder.p_times)
